<template>
	<view>
		<u-sticky>
			<uni-nav-bar left-icon="back" @clickLeft="$tab.back()" title="熵豆投放量" :statusBar="true"
				:border="false"></uni-nav-bar>

			<div class="px-20 mt-20">
				<div class="nav-data">
					<div class="flex flex-col items-center">
						<div class="text-FFF">
							<span class="text-48">340</span>
							<span class="text-24">万</span>
						</div>
						<div class="" style="color: #FFDCC2;">
							总投放量/个
						</div>
					</div>

					<div class="flex items-center justify-between" style="margin-top: 64rpx;" v-if="detail">
						<div class="">
							<div class="">
								<span style="color:#FFDCC2;font-size: 32rpx;">总释放:</span>
								<span class="font-700 text-FFF">{{detail.released}}个</span>
							</div>

							<div class="mt-40">
								<span style="color:#FFDCC2;font-size: 32rpx;">总销毁:</span>
								<span class="font-700 text-FFF">{{detail.destroyed}}个</span>
							</div>
						</div>
						<div class="nav-line">

						</div>

						<div class="">
							<div class="">
								<span style="color:#FFDCC2;font-size: 32rpx;">未释放:</span>
								<span class="font-700 text-FFF">{{detail.norelease}}个</span>
							</div>

							<div class="mt-40">
								<span style="color:#FFDCC2;font-size: 32rpx;">当日销毁:</span>
								<span class="font-700 text-FFF">{{detail.destroyedToday}}个</span>
							</div>
						</div>
					</div>
				</div>
			</div>
		</u-sticky>


		<div class="px-20 mt-16">
			<div class=" round-20 bg-FFF p-32">
				<u-tabs :list="tabsList" :current="tabIndex" lineWidth="30" lineColor="#FF540A" :activeStyle="{
				            color: '#FF540A',
				            fontWeight: 'bold',
				            transform: 'scale(1.05)'
				        }" :inactiveStyle="{
				            color: '#606266',
				            transform: 'scale(1)'
				        }" @click="handleTab">
				</u-tabs>
				<div class="mt-32"></div>
				<s-pull-scroll ref="pullScroll" :pullDown="pullDown" :pullUp="loadData" :fixed="false">
					<view class="" v-for="(item,index) in list" :key="index">
						<view class="item">
							<view class="flex justify-between items-center">
								<text class="text-36" style="max-width: 450rpx;">{{item.useRemark}}</text>
								<text class="text-36 font-700" :style="{color:item.payment==1 ? '#02CE8A' : '#FF912A'}">
									{{item.payment==1 ? '+'+item.amount : '-'+item.amount}}
								</text>
							</view>
							<view class="flex justify-between items-center mt-20">
								<text class="text-gray">{{item.createTime}}</text>
								<text class="text-gray">余额：{{item.balance}}
									</text>
							</view>
						</view>
						<u-divider></u-divider>
					</view>
				</s-pull-scroll>
			</div>
		</div>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				detail: null,
				list: [],
				tabsList: [{
					name: "我已释放"
				}, {
					name: "我已销毁"
				}],
				tabIndex: 0
			};
		},
		onLoad() {
			this.getData()
			this.refresh()
		},
		methods: {
			handleTab(e) {
				this.tabIndex = e.index
				this.refresh()
			},
			async getData() {
				const res = await this.$Api.property.shangdouData()
				this.detail = res.data
			},
			refresh() {
				this.$nextTick(() => {
					this.$refs.pullScroll.refresh();
				});
			},
			pullDown(pullScroll) {
				setTimeout(() => {
					this.loadData(pullScroll);
				}, 200);
			},
			loadData(pullScroll) {
				setTimeout(async () => {
					if (pullScroll.page == 1) {
						this.list = [];
					}
					const res = await this.$Api.property.shangdouRecord({
						pageNum: pullScroll.page,
						pageSize: 20,
						key: this.tabIndex == 0 ? 'released' : 'destroyed'
					})
					this.list = this.list.concat(res.rows);
					if (this.list.length >= res.total) {
						pullScroll.finish();
					} else {
						pullScroll.success();
					}
				}, 500);
			}
		},
	}
</script>

<style lang="scss">
	.nav-data {
		height: 340rpx;
		background: url('https://file.fulewanjia.com/fulewanjia/profile/appImages5/bg@3x-3.png') no-repeat;
		background-size: 100% 100%;
		padding: 40rpx 28rpx 0 28rpx;
	}

	.nav-line {
		width: 2rpx;
		height: 50rpx;
		background: #FFF;
	}

	/deep/ .u-sticky {
		top: 0 !important;
	}
</style>